package com.goambu.driver.utils;

import java.util.Locale;

import com.goambu.driver.GoAmbuDriverConstants;
import com.goambu.driver.autenticacion.controller.MyGeocoderController;
import com.goambu.driver.autenticacion.entities.DestinyResponse;
import com.goambu.driver.autenticacion.entities.GeocoderResponse;

public class MyGeocoder {

public static GeocoderResponse getFromLocation(double lat, double lng, int maxResult){
		Locale locale = new Locale("es", "PE");
		String address = "https://maps.googleapis.com/maps/api/geocode/json?latlng="+lat+","+lng+"&sensor=true&language="+locale.getLanguage()+"&key="+GoAmbuDriverConstants.GOOGLE_API_SERVER_KEY;
		GeocoderResponse resaddress = null;
		//System.out.println("wiwiwiwiwiwiwiwiwi   address: "+address);
		
		try {
			resaddress = MyGeocoderController.getFromLocation(address);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return resaddress;
	}

	public static DestinyResponse getTravelToDestinyInfo(double orglat, double orglng, double deslat, double deslng, int maxResult){
		Locale locale = new Locale("es", "PE");
		String address = "https://maps.googleapis.com/maps/api/directions/json?origin="+orglat+","+orglng+"&destination="+deslat+","+deslng+"&sensor=true&language="+locale.getLanguage()+"&key="+GoAmbuDriverConstants.GOOGLE_API_SERVER_KEY;
		DestinyResponse resaddress = null;
		//System.out.println("wiwiwiwiwiwiwiwiwi   address: "+address);
		
		try {
			resaddress = MyGeocoderController.getDestinyInfoFromLocation(address);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return resaddress;
	}
}
